import fetch from './index.js'
import { getLoca } from '../assets/js/common'

export const test = () => fetch('http://192.168.88.63:2231/login/login',{
	username:'123',
	password:'123'
},"POST",'all')

//登录
export const login = (username, password) => fetch('api/userapi.php', {
	act: 'login',
	username,
	password
})

//登出
export const loginOut = () => fetch('api/userapi.php',{
	act:'logout'
})

//获取资金信息
export const getAccount = (username) => fetch('api/userapi.php', {
	act: 'getAccount',
	username: getLoca('userInfo')['username']
})

// 发送验证码
export const phoneCode = (username,mobile) => fetch('api/userapi.php',{
	act:'getMobileCode',
	username,
	mobile
})
//结算财务
export const caiwuapi = () => fetch('api/caiwuapi.php', {
	act: 'zhuanzhang_list',
	username: getLoca('userInfo')['username'],

})

//结算财务记录
export const caiwuapiList = () => fetch('api/caiwuapi.php', {
	act: 'caiwulist',
	username: getLoca('userInfo')['username'],

})

//结算财务 发送验证码
export const caiwuapiSendcode = () => fetch('api/userapi.php', {
	act: 'getMobileCode',
	username: getLoca('userInfo')['username'],
	mobile: getLoca('userInfo')['mobile'],
})

//结算提交
export const caiwuapiApply = ( type, num, code) => fetch('api/caiwuapi.php', {
	act: 'apply',
	username: getLoca('userInfo')['username'],
	type,
	num,
	code
})

//密码修改
export const passEdie = ( mobile, newpwd, confirmpwd, code, type, username = 'username' ) => {
	if(username === '') username = getLoca('userInfo')['username']

	return fetch('api/userapi.php', {
		act: 'editpwd',
		username,
		mobile,
		newpwd,
		confirmpwd,
		code,
		type,
	})
}

//发送验证码
export const sendCode = (mobile) => fetch('api/userapi.php',{
	act:'getMobileCode',
	username: getLoca('userInfo')['username'],
	mobile
})

export const getUserInfo = () => {
	return new Promise( (resolve, rejext) => {
		resolve(getLoca('userInfo'))
	})
}

// 业务注册
export const regiset = (act,username,nickname,tjuser,gluser,pos,mobile,code) => fetch('api/userapi.php',{
	act,
	username,
	nickname,
	tjuser,
	gluser,
	pos,
	mobile,
	code
})

// 奖金明细
export const bouns = (act) => fetch('api/userapi.php',{
	act,
	username:getLoca('userInfo')['username']
})

//会员编号验证
export const userCodeVis = (username) => fetch('api/ajax.php',{
	act:'chkusername',
	username
})

//分享王编号验证
export const shareVis = (tjuser) => fetch('api/ajax.php',{
	act:'chktjuser',
	tjuser,
})

//部落王编号
export const tribe = (tjuser,gluser) => fetch('api/ajax.php',{
	act:'chkgluser',
	gluser,
	tjuser
})

//位置验证
export const position = (tjuser,gluser, pos) => fetch('api/ajax.php',{
	act:'chkpos',
	tjuser,
	gluser,
	pos
})
